package com.other;

import com.zhl.config.DisplayNameCondition;
import com.zhl.config.FeignLocal;
import com.zhl.config.LocalFeignTargeter;
import feign.Feign;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.cloud.openfeign.Targeter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;

@Configuration
public class CustomeFeignConfigure {

//    @Bean
//    public Client LocalBlockingFeignClient(){
//        return new LocalBlockingFeignClient();
//    }



    @Bean
//    @ConditionalOnExpression("#{ applicationContext.displayName == 'myAppContext' }")
   // @Conditional(DisplayNameCondition.class)

    @ConditionalOnProperty(name = "local.feign.enabled", havingValue = "true")
    public Targeter localFeignTargeter(DispatcherServlet dispatcherServlet){
        return new LocalFeignTargeter(dispatcherServlet);
    }

    @Bean
//    @ConditionalOnExpression("#{ applicationContext.displayName == 'myAppContext' }")
    //@Conditional(DisplayNameCondition.class)
    @ConditionalOnProperty(name = "local.feign.enabled", havingValue = "true")
    public Feign.Builder build(){
        return FeignLocal.builder();
    }

}
